package com.cjy.runnable.demo3;

/**
 * @author Cheng JiYe
 * @description:
 * @date 2021/4/24 23:46
 */
public class ThreadJoinDemo {
  public static void main(String[] args) {
    // 实例化Runnable子类对象
    MyThread mt = new MyThread();
    // 实例化Thread对象
    Thread t = new Thread(mt, "线程");
    t.start(); // 启动线程
    for (int i = 0; i < 50; i++) {
      if (i > 10) {
        try {
          t.join(); // 线程强制运行
        } catch (InterruptedException e) {
        }
      }
      System.out.println("Main线程运行 --> " + i);
    }
  }
}
